<%--
  Created by IntelliJ IDEA.
  User: qianghj
  Date: 2020/9/28
  Time: 10:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-3.4.1.min.js"></script>
    <script src="js/jquery.form.js"></script>
    <script src="js/ajaxfileupload.js"></script>
</head>
<body>
<form method="post" enctype="multipart/form-data" id="imgform">
    <input type="file" name="myfile" id="myfile">
</form>

<div id="preview">
</div>

<script type="text/javascript" language="JavaScript" >

    $('#myfile').change( function() {
        $("#imgform").ajaxSubmit({
            url: "qiniu/upload",
            method: 'POST',
            datType: 'json',
            success: function (data) {
                console.log(data.imgUrl);  // 在七牛云 服务器的URL
                var ele = "<img src=\"\"/>"
                $("#preview").append(ele);
                $("#preview").find("img").attr("src",data.imgUrl);
            },
            error: function (data) {
                alert(data);
            }
        })
    })
</script>
</body>
</html>
